package com.ruoyi.framework.config;

import com.ruoyi.framework.interceptor.LoginApiInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class InterceptorConfiguration implements WebMvcConfigurer {

    @Resource
    private LoginApiInterceptor loginApiInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截小程序接口
        registry.addInterceptor(loginApiInterceptor)
            .addPathPatterns("/api/**")
            //放行的接口
            .excludePathPatterns(
                "/**/login",
                "/**/test",
                "/**/register-or-login",
                "/api/miniapp/user/share-test",
                "/**/authorization",
                "/api/miniapp/file/upload",
                "/**/check",

                "/api/miniapp/order/**",
                "/api/miniapp/product/**",
                "/api/miniapp/user/queryCanUserMyProductLog"
            );

    }


}
